<?php echo $row['membertype']?>问题

来源:百度知道 编辑:UC知道 时间:2024/09/24 10:10:40
当 membertype= 1 时显示:A
当 membertype= 2 时显示:B
当 membertype= 3 时显示:C

这个该怎么实现?

首先,你的分号不应该遗漏:
<?php echo $row['membertype'];?>

其次:membertype的值与你的代码无关,因为你的代码是显示数组的值:
echo $row['membertype'];

最后:
把1,2,3……转换为A,B,C,……的例子代码如下:
<?php
$n=2;
$str=chr(ord('A')+$n-1);
echo $str;
?>

switch($row['membertype']){
case 1:
echo 'A';break;
case 2:
echo 'B';break;
case 3:
echo 'C';break;
}